For several programming languages, an inlining method is employed as an optimization method. Inlining is a method whereby the description of a program is changed by embedding, in a calling source, the contents of the definition of a function, so that a process can be performed without function calls being required. As a result, since with this method no overhead is required for function calls, execution speed is increased.
In addition, for several programming languages a system is provided wherein, by declaring a specific area, an exception handler relevant to that area is used to process an exception occurring in that area during the execution of a program. In the Java™ programming language, which is one of the programming languages employing this system, this declaration is called a “try”, and an area that is declared is called a try area or a try block. In the following explanation, in accordance with the Java™ programming languages, the declaration and the area are referred to as a try and a try area.
A programming language that enables the use of descriptions for multiple synchronous threads is essential when writing a system program for the construction of a complicated and reliable network including a sewer, or servers, and clients. An example programming language that satisfies this need is the Java™ programming language.
In the Java™ programming language, two critical sections called a synchronized method and a synchronized block can be described. Upon the occurrence of an exception, an execution system always unlocks these critical sections.
Further, the Java™ programming language is one of the programming languages that include a system forte implementation of the previously mentioned miming and try.
During the optimization process performed by a compiler (hereinafter referred to as a Java™ compiler) while compiling a program written in the Java™ programming language, when inlining is employed for a synchronized method, not only is it possible to acquire certain general effects, such as reduced costs accruing from the elimination of call functions, the transmission of constants and the transmission of class information, but also to remove redundant synchronization procedures.
However, to perform inlining, the number of resource locks, which is a use limit imposed in order to ensure exclusive resource use during a predetermined process, is increased and exceeds the number that is established by the language specifications. Therefore, an exception handling using a try is complicated for a program wherein inlining has been used for the synchronized method.
FIG. 8 is a diagram for explaining a conventional exception handling for a Java™ program wherein inlining is used for a synchronized method (hereinafter referred to simply as a method).
In the example in FIG. 8, for inlining, method A calls method B, and then method B calls method C. Method C is inlined in the try area for method B, and methods B and C lock an object at their entrances using the synchronized method.
In this example, assume that an exception E occurs in the inlined method C, and is caught by an exception handler in a try area T for the method B.
In this case, since the exception is processed outside the method C, the exception handler must unlock method C while maintaining the lock on method B. Therefore, the exception handler must be aware that the locks on methods B and C are set when an exception E is thrown, and the lock on method B is set when the exception handler for the try area T is executed. That is, data is required concerning the lock set upon the occurrence of an exception and the lock set upon the execution of the exception handler.
A Java™ compiler can include information (hereinafter referred to as inline information) for a correlation of a code area and an inlined method. The inline information indicates a called method to which the code originally belonged. Therefore, in the example in FIG. 8, while referring to the address whereat the exception is generated, the exception handler obtains the inline information “method A→method B→method C (this order shows that these methods are originally called; hereinafter, in the inline information “method” is eliminated).” Further referring to the address whereat the exception E is caught the inline information “A→B” is obtained. By comparing the inline information, the lock performed by method C is specified and released.
A conventional Java™ compiler prepares, as the above described inline information, a table of address intervals and inline information, or a table of addresses for relevant exception commands (an exception occurrence probable command, an exception handler head command and a method calling command) and the inline information. When an exception has occurred, an exception handler employs an address whereat the exception occurred and an address whereat the exception is caught to find a table corresponding to these addresses, and searches the table for desired inline information.
[Problems to be Solved by the Invention]
However, in order to obtain the inline information, the conventional Java™ compiling method requires two processes: a process for searching a table based on the address, and a process for searching for the inline information based on the obtained table. Therefore, the time required for these processes greatly affects the operating cost of the entire exception handling, and can not be ignored.
Further, according to the method used to obtain the inline information using the above table, there is a case wherein the locked state obtained from the inline information does not match the actual locked state. For example, for a case wherein a redundant lock is deleted by the optimization, even if the inline information indicates the inlined synchronized method, a lock due to the synchronized method is not always present.
It is, therefore, one object of the present invention to provide a compiling method and a method for performing an exception handling that will reduce the operating costs required for the acquisition of data concerning a lock needed for an exception handling, and to reduce the affect on the operating cost required for the exception handling. It is another object of the present invention to provide a method for the necessary release of a lock when an exception has occurred and for performing an exception handling.